﻿namespace Hidistro.UI.SaleSystem.CodeBehind
{
    using Hidistro.Core;
    using Hidistro.Entities;
    using Hidistro.Entities.Commodities;
    using Hidistro.Entities.VShop;
    using Hidistro.Membership.Context;
    using Hidistro.SaleSystem.Catalog;
    using Hidistro.SaleSystem.Vshop;
    using Hidistro.UI.Common.Controls;
    using Hishop.Plugins;
    using System;
    using System.Collections.Generic;
    using System.Collections.Specialized;
    using System.Data;
    using System.Globalization;
    using System.IO;
    using System.Text;
    using System.Text.RegularExpressions;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;

    [ParseChildren(true)]
    public class VDefault : VshopTemplatedWebControl
    {
        private HtmlImage img;
        private VshopTemplatedRepeater rptNavigate;
        private VshopTemplatedRepeater rptProducts;
        private VshopTemplatedRepeater rptSlide;
        private VshopTemplatedRepeater rptTopic;


        private int categoryId = 6;
        private HiImage imgUrl;
        private string keyWord;
        private Literal litContent;
        private VshopTemplatedRepeater rptCategories;
        private VshopTemplatedRepeater rptProductsone;
        private HtmlInputHidden txtTotalPages;


        private VshopTemplatedRepeater rptCategoriesOnes;
        private VshopTemplatedRepeater rptProducts1;

        private VshopTemplatedRepeater Vshoptemplatedrepeater_yanshi;
        private VshopTemplatedRepeater Vshoptemplatedrepeater_two;
        private VshopTemplatedRepeater Vshoptemplatedrepeater_three;
        private VshopTemplatedRepeater Vshoptemplatedrepeater_four;

        private VshopTemplatedRepeater Vshoptemplatedrepeater_five;

        private VshopTemplatedRepeater Vshoptemplatedrepeater_six;

        private VshopTemplatedRepeater Vshoptemplatedrepeater1;

        private VshopTemplatedRepeater Vshoptemplatedrepeaterhot;

        private VshopTemplatedRepeater VshoptemplatedrepeaterGirlGarden;

        private VshopTemplatedRepeater VshoptemplatedrepeaterGirlGarden2;

        private VshopTemplatedRepeater Vshoptemplatedrepeatermen;

        private VshopTemplatedRepeater Vshoptemplatedrepeatertaotao;

        private VshopTemplatedRepeater Vshoptemplatedrepeaterleft_shop;

        private VshopTemplatedRepeater Vshoptemplatedrepeaterbaojiang;

        private VshopTemplatedRepeater Vshoptemplatedrepeateryanchi;

        private VshopTemplatedRepeater Vshoptemplatedrepeaterlast;

        protected override void AttachChildControls()
        {
            PageTitle.AddSiteNameTitle("首页");
            this.rptSlide = (VshopTemplatedRepeater)this.FindControl("rptSlide");
            this.rptNavigate = (VshopTemplatedRepeater)this.FindControl("rptNavigate");
            this.rptTopic = (VshopTemplatedRepeater)this.FindControl("rptTopics");
            this.rptProducts = (VshopTemplatedRepeater)this.FindControl("rptProducts");
            this.img = (HtmlImage)this.FindControl("imgDefaultBg");
            if (this.rptSlide != null)
            {
                this.rptSlide.DataSource = VshopBrowser.GetAllBanners(ClientType.VShop);
                this.rptSlide.DataBind();
            }
            if (this.rptProducts != null)
            {
                DataTable homeProduct = ProductBrowser.GetHomeProduct(ClientType.VShop);
                this.rptProducts.DataSource = homeProduct;
                this.rptProducts.DataBind();
            }
            if (this.rptTopic != null)
            {
                DataTable topics = VshopBrowser.GetTopics(ClientType.VShop);
                this.rptTopic.DataSource = topics;
                this.rptTopic.DataBind();
            }
            if (this.rptNavigate != null)
            {
                IList<NavigateInfo> allNavigate = VshopBrowser.GetAllNavigate(ClientType.VShop);
                foreach (NavigateInfo info in allNavigate)
                {
                    if (!(info.ImageUrl.ToLower().Contains("storage/master/navigate") || info.ImageUrl.ToLower().Contains("templates")))
                    {
                        info.ImageUrl = HiContext.Current.GetVshopSkinPath(null) + "/images/deskicon/" + info.ImageUrl;
                    }
                }
                this.rptNavigate.DataSource = allNavigate;
                this.rptNavigate.DataBind();
            }
            if (this.img != null)
            {
                this.img.Src = new VTemplateHelper().GetDefaultBg();
            }


            int num;
            int num2;
            int num3;
            int.TryParse(this.Page.Request.QueryString["categoryId"], out this.categoryId);
            this.keyWord = this.Page.Request.QueryString["keyWord"];
            if (!string.IsNullOrWhiteSpace(this.keyWord))
            {
                this.keyWord = this.keyWord.Trim();
            }
            this.imgUrl = (HiImage)this.FindControl("imgUrl");
            this.litContent = (Literal)this.FindControl("litContent");
            this.rptProductsone = (VshopTemplatedRepeater)this.FindControl("rptProductsone");
            this.rptCategories = (VshopTemplatedRepeater)this.FindControl("rptCategories");
            this.txtTotalPages = (HtmlInputHidden)this.FindControl("txtTotal");
            string str = this.Page.Request.QueryString["sort"];
            if (string.IsNullOrWhiteSpace(str))
            {
                str = "DisplaySequence";
            }
            string str2 = this.Page.Request.QueryString["order"];
            if (string.IsNullOrWhiteSpace(str2))
            {
                str2 = "desc";
            }
            if (!int.TryParse(this.Page.Request.QueryString["page"], out num))
            {
                num = 1;
            }
            if (!int.TryParse(this.Page.Request.QueryString["size"], out num2))
            {
                num2 = 20;
            }
            this.categoryId = 6;


            num2 = 20;
            this.rptProductsone.DataSource = ProductBrowser.GetProducts(null, new int?(this.categoryId), this.keyWord, 0, num, num2, out num3, str, str2);
            this.rptProductsone.DataBind();
            this.txtTotalPages.SetWhenIsNotNull(num3.ToString());
            PageTitle.AddSiteNameTitle("分类搜索页");
            //分类菜单

            int.TryParse(this.Page.Request.QueryString["categoryId"], out this.categoryId);
            this.keyWord = this.Page.Request.QueryString["keyWord"];
            this.imgUrl = (HiImage)this.FindControl("imgUrl");
            this.litContent = (Literal)this.FindControl("litContent");
            this.rptProducts1 = (VshopTemplatedRepeater)this.FindControl("rptProducts1");
            this.rptCategoriesOnes = (VshopTemplatedRepeater)this.FindControl("rptCategoriesOnes");
            this.categoryId = 20;
            IList<CategoryInfo> maxSubCategories = CategoryBrowser.GetMaxSubCategories(this.categoryId, 0x3e8);
            this.rptCategoriesOnes.DataSource = maxSubCategories;
            this.rptCategoriesOnes.DataBind();
            PageTitle.AddSiteNameTitle("分类搜索页");


            this.Vshoptemplatedrepeater_yanshi = (VshopTemplatedRepeater)this.FindControl("Vshoptemplatedrepeater_yanshi");
            this.categoryId = 17;
            IList<CategoryInfo> maxSubCategoriesone = CategoryBrowser.GetMaxSubCategories(this.categoryId, 0x3e8);
            this.Vshoptemplatedrepeater_yanshi.DataSource = maxSubCategoriesone;
            this.Vshoptemplatedrepeater_yanshi.DataBind();
            PageTitle.AddSiteNameTitle("分类搜索页");


            this.Vshoptemplatedrepeater_two = (VshopTemplatedRepeater)this.FindControl("Vshoptemplatedrepeater_two");
            this.categoryId = 13;
            IList<CategoryInfo> maxSubCategoriestwo = CategoryBrowser.GetMaxSubCategories(this.categoryId, 0x3e8);
            this.Vshoptemplatedrepeater_two.DataSource = maxSubCategoriestwo;
            this.Vshoptemplatedrepeater_two.DataBind();
            PageTitle.AddSiteNameTitle("分类搜索页");



            this.Vshoptemplatedrepeater_three = (VshopTemplatedRepeater)this.FindControl("Vshoptemplatedrepeater_three");
            this.categoryId = 9;
            IList<CategoryInfo> maxSubCategoriesthree = CategoryBrowser.GetMaxSubCategories(this.categoryId, 0x3e8);
            this.Vshoptemplatedrepeater_three.DataSource = maxSubCategoriesthree;
            this.Vshoptemplatedrepeater_three.DataBind();
            PageTitle.AddSiteNameTitle("分类搜索页");

            this.Vshoptemplatedrepeater_four = (VshopTemplatedRepeater)this.FindControl("Vshoptemplatedrepeater_four");
            this.categoryId = 30;
            IList<CategoryInfo> maxSubCategoriestfour = CategoryBrowser.GetMaxSubCategories(this.categoryId, 0x3e8);
            this.Vshoptemplatedrepeater_four.DataSource = maxSubCategoriestfour;
            this.Vshoptemplatedrepeater_four.DataBind();
            PageTitle.AddSiteNameTitle("分类搜索页");




            this.Vshoptemplatedrepeater_five = (VshopTemplatedRepeater)this.FindControl("Vshoptemplatedrepeater_five");
            this.categoryId = 1;
            IList<CategoryInfo> maxSubCategoriestfive = CategoryBrowser.GetMaxSubCategories(this.categoryId, 0x3e8);
            this.Vshoptemplatedrepeater_five.DataSource = maxSubCategoriestfive;
            this.Vshoptemplatedrepeater_five.DataBind();
            PageTitle.AddSiteNameTitle("分类搜索页");


            this.Vshoptemplatedrepeater_six = (VshopTemplatedRepeater)this.FindControl("Vshoptemplatedrepeater_six");
            this.categoryId = 5;
            IList<CategoryInfo> maxSubCategoriestsix = CategoryBrowser.GetMaxSubCategories(this.categoryId, 0x3e8);
            this.Vshoptemplatedrepeater_six.DataSource = maxSubCategoriestsix;
            this.Vshoptemplatedrepeater_six.DataBind();
            PageTitle.AddSiteNameTitle("分类搜索页");






            this.rptProducts = (VshopTemplatedRepeater)this.FindControl("rptProducts");
            this.img = (HtmlImage)this.FindControl("imgDefaultBg");
            if (this.rptSlide != null)
            {
                this.rptSlide.DataSource = VshopBrowser.GetAllBanners(ClientType.VShop);
                this.rptSlide.DataBind();
            }
            if (this.rptProducts != null)
            {
                DataTable homeProduct = ProductBrowser.GetHomeProduct(ClientType.VShop);
                this.rptProducts.DataSource = homeProduct;
                this.rptProducts.DataBind();
            }
            if (this.rptTopic != null)
            {
                DataTable topics = VshopBrowser.GetTopics(ClientType.VShop);
                this.rptTopic.DataSource = topics;
                this.rptTopic.DataBind();
            }
            if (this.rptNavigate != null)
            {
                IList<NavigateInfo> allNavigate = VshopBrowser.GetAllNavigate(ClientType.VShop);
                foreach (NavigateInfo info in allNavigate)
                {
                    if (!(info.ImageUrl.ToLower().Contains("storage/master/navigate") || info.ImageUrl.ToLower().Contains("templates")))
                    {
                        info.ImageUrl = HiContext.Current.GetVshopSkinPath(null) + "/images/deskicon/" + info.ImageUrl;
                    }
                }
                this.rptNavigate.DataSource = allNavigate;
                this.rptNavigate.DataBind();
            }
            if (this.img != null)
            {
                this.img.Src = new VTemplateHelper().GetDefaultBg();
            }





            this.Vshoptemplatedrepeater1 = (VshopTemplatedRepeater)this.FindControl("Vshoptemplatedrepeater1");
            this.rptCategories = (VshopTemplatedRepeater)this.FindControl("rptCategories");
            this.txtTotalPages = (HtmlInputHidden)this.FindControl("txtTotal");








            this.categoryId = 1;

            num2 = 1;

            this.txtTotalPages.SetWhenIsNotNull(num3.ToString());
            PageTitle.AddSiteNameTitle("分类搜索页");




            this.Vshoptemplatedrepeatertaotao = (VshopTemplatedRepeater)this.FindControl("Vshoptemplatedrepeatertaotao");

            this.categoryId = 5;

            num2 = 1;

            this.txtTotalPages.SetWhenIsNotNull(num3.ToString());
            PageTitle.AddSiteNameTitle("分类搜索页");


            this.Vshoptemplatedrepeaterleft_shop = (VshopTemplatedRepeater)this.FindControl("Vshoptemplatedrepeaterleft_shop");

            this.categoryId = 31;

            num2 = 1;


            this.txtTotalPages.SetWhenIsNotNull(num3.ToString());
            PageTitle.AddSiteNameTitle("分类搜索页");



            this.Vshoptemplatedrepeaterbaojiang = (VshopTemplatedRepeater)this.FindControl("Vshoptemplatedrepeaterbaojiang");

            this.categoryId = 14;

            num2 = 1;

            this.txtTotalPages.SetWhenIsNotNull(num3.ToString());
            PageTitle.AddSiteNameTitle("分类搜索页");



            this.Vshoptemplatedrepeateryanchi = (VshopTemplatedRepeater)this.FindControl("Vshoptemplatedrepeateryanchi");

            this.categoryId = 18;

            num2 = 1;

            this.txtTotalPages.SetWhenIsNotNull(num3.ToString());
            PageTitle.AddSiteNameTitle("分类搜索页");

            this.Vshoptemplatedrepeaterlast = (VshopTemplatedRepeater)this.FindControl("Vshoptemplatedrepeaterlast");

            this.categoryId = 66;

            num2 = 1;

            this.txtTotalPages.SetWhenIsNotNull(num3.ToString());



        }





        //加载模版
        protected override void OnInit(EventArgs e)
        {
            if (this.SkinName == null)
            {
                this.SkinName = "skin-vindex.html";
            }
            base.OnInit(e);
        }



    }
}

